package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread swart = new Thread("斯沃特"){
            public void run(){
                for (int i = 0; i < 2; i++) {
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                    }
                    System.out.println(getName() + ":A点集合!");
                }
                System.out.println("轰!!");
            }
        } ;
        Thread omo = new Thread("奥摩"){
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(2100);
                        System.out.println(getName()+":手雷来了!");
                    } catch (InterruptedException e) {
                    }
                }
            }
        };
        swart.start();
        omo.setDaemon(true);
        omo.start();

        //while (true);//如果主线程死循环 那么守护线程将不死

    }
}
